package Thread;
class MyThraed2 extends Thread{
    @Override
    public void run() {
        while(true){
            System.out.println("hello Thread");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
public class ThreadDemo2 {
    //可通过jdk—bin—jconsol来监视线程
    public static void main(String[] args) {
        //t线程中
        MyThraed2 t = new MyThraed2();
        t.start();
        //主线程中
        //两个独立的执行流
        while(true){
            System.out.println("hello true");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
